package com.hb.trans.mvp.model

import com.basiclib.base.BaseModel
import com.hb.trans.api.EndPoints
import com.hb.trans.api.TRANS_SERVER_PATH
import com.hb.trans.bean.Base
import com.hb.trans.bean.Student
import com.hb.trans.mvp.contract.TransCheckLoginContract
import io.reactivex.Observable
import okhttp3.ResponseBody
import javax.inject.Inject

class TransCheckLoginModel @Inject constructor(var api: EndPoints) : BaseModel(), TransCheckLoginContract.Model {
    //登录
    override fun login(
        phone: String,
        cardCode: String,
        carType: String,
        verifyCode: String,
        key: String
    ): Observable<Base<Student>> {
        return api.login(
            "${TRANS_SERVER_PATH}stuInfo/view",
            params = mutableMapOf(
                "imageCode" to verifyCode,
                "phone" to phone,
                "idCard" to cardCode,
                "traintype" to carType,
                "key" to key
            )
        )
    }

    //获取验证码
    override fun securityCode(key: String): Observable<ResponseBody> {
        return api.securityImage(TRANS_SERVER_PATH + "image/getCode", key)
    }
}
